Skip to content

Add non-blocking TX primitives: tx_fifo_full and try_putchar - #2

Merged
luodeb merged 1 commit into
arceos-org:mainfrom
luodeb:add-try-putchar
Sep 14, 2026
Merged

luodeb merged 1 commit into
arceos-org:mainfrom
luodeb:add-try-putchar

Conversation

@luodeb

@luodeb luodeb commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

@/tmp/pr2-body.md

putchar polls FR[TXFF] forever, which is unusable in contexts that must
bound their waiting (interrupt handlers, NMI/emergency console output,
panic paths). Expose the polling condition and a non-blocking variant:

- tx_fifo_full(): read FR[TXFF] directly;
- try_putchar(): write DR only when the TX FIFO has space, reporting
  success/failure instead of blocking.

putchar is now a loop over try_putchar, so its behavior is unchanged.
Host unit tests exercise both paths against a simulated register block.

Motivation: the x-kernel emergency console (NMI-safe printk) needs a
bounded UART send on PL011; with this API it can reuse the crate instead
of open-coding FR/DR volatile accesses.

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude <noreply@anthropic.com>
@luodeb
luodeb requested review from equation314 and a lite review from Copilot September 11, 2026 08:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Import or qualify size_of in the test module to resolve the compilation failures.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds non-blocking PL011 transmit helpers while preserving putchar’s blocking behavior.

Changes:

  • Adds tx_fifo_full() and try_putchar().
  • Refactors putchar() to reuse try_putchar().
  • Adds simulated-register unit tests.
File summaries
File Summary
src/pl011.rs Implements TX helpers and tests; test code has unresolved size_of references.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/pl011.rs
Comment on lines +127 to +128
use super::*;

@luodeb
luodeb merged commit e097bae into arceos-org:main Sep 14, 2026
5 checks passed
luodeb added a commit that referenced this pull request Sep 14, 2026
For the non-blocking TX primitives added in #2 (tx_fifo_full,
try_putchar).

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants